<template>
  <div class="Login-Content">
    <el-card class="Login-form">
      <div slot="header" class="clearfix">
        <span>登录</span>
      </div>
      <div>
        <el-form ref="form" :model="form" label-width="60px" size="small">
          <el-form-item label="用户名">
            <el-input v-model="form.name" placeholder="请输入用户名"></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="form.pwd" type="password" placeholder="密码"></el-input>
          </el-form-item>
          <div class="Login-Form-btn">
            <el-button type="primary" size="small" @click="Login">登录</el-button>
          </div>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        name: 'admin',
        pwd: '111111',
      },
    };
  },
  methods: {
    Login() {
      const Loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      });
      const { name, pwd } = this.form;
      setTimeout(() => {
        Loading.close();
        if (name != 'admin' || pwd != '111111') {
          this.$message.error('账号或者密码错误');
        } else {
          this.$message.success('登录成功');

          const type = this.$initUtils.getUrlKey('type');
          console.log(type);
          if (type == 1) {
            console.log('aaaaa');
            this.$router.push({ name: 'HomeTwo' });
            return;
          }

          this.$router.push({ name: 'Home' });
        }
      }, 2000);
    },
  },
};
</script>

<style lang="less" scoped>
body {
  margin: 0;
  padding: 0;
}
.Login-Content {
  width: 100%;
  height: 100%;
  background-color: #2b4b6b;
  min-height: 100vh;
}
.Login-form {
  width: 400px;
  height: 300px;
  position: fixed;
  top: 50%;
  left: 80%;
  transform: translate(-50%, -50%);
}
.Login-Form-btn {
  text-align: center;
  margin-top: 30px;
}
</style>
